package com.heima.article.task;

import com.heima.article.service.IApArticleService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class HotArticleTask {


    @Autowired
    private IApArticleService apArticleService;

//    //@Scheduled(cron = "0 0 1 * * ?")
//    @Scheduled(cron = "0/10 * * * * ?")
//    public void computeHotArticle() {
//        apArticleService.computeHotArticle();
//    }

    @XxlJob("computeHotArticleJob")
    public ReturnT<String> computeHotArticleJob(String param) throws Exception {
        try {
            apArticleService.computeHotArticle();
        } catch (Exception e) {
            e.printStackTrace();
            return ReturnT.FAIL;
        }
        return ReturnT.SUCCESS;
    }
}
